package com.phiture.erp.finance.core.service;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.phiture.erp.finance.core.pojo.dto.PageErpFinanceStatementDTO;
import com.phiture.erp.finance.core.pojo.vo.ErpFinanceStatementPageReqVO;
import com.phiture.erp.finance.core.pojo.vo.ErpFinanceStatementSaveReqVO;
import com.phiture.erp.finance.core.pojo.vo.ErpFinanceStatementVO;
import com.phiture.erp.finance.dal.entity.ErpFinanceStatementDO;
import com.phiture.erp.finance.dal.entity.ErpFinanceStatementItemsDO;

import javax.validation.Valid;
import java.util.Collection;
import java.util.List;

/**
 * 对账单 Service 接口
 *
 * @author 芋道源码
 */
public interface ErpFinanceStatementService {

    /**
     * 创建对账单
     *
     * @param createReqVO 创建信息
     * @return 编号
     */
    Long createFinanceStatement(@Valid ErpFinanceStatementSaveReqVO createReqVO);

    /**
     * 更新对账单
     *
     * @param updateReqVO 更新信息
     */
    void updateFinanceStatement(@Valid ErpFinanceStatementSaveReqVO updateReqVO);

    /**
     * 更新对账单的状态
     *
     * @param id 编号
     * @param status 状态
     */
    void updateFinanceStatementStatus(Long id, Integer status);

    /**
     * 删除对账单
     *
     * @param id 编号
     */
    void deleteFinanceStatement(Long id);

    /**
     * 获得对账单
     *
     * @param id 编号
     * @return 对账单
     */
    ErpFinanceStatementDO getFinanceStatement(Long id);

    /**
     * 获得对账单分页
     *
     * @param pageReqVO 分页查询
     * @return 对账单分页
     */
    PageResult<ErpFinanceStatementDO> getFinanceStatementPage(ErpFinanceStatementPageReqVO pageReqVO);

    // ==================== 子表（对账单明细） ====================

    /**
     * 获得对账单明细列表
     *
     * @param statementId 对账单 ID
     * @return 对账单明细列表
     */
    List<ErpFinanceStatementItemsDO> getFinanceStatementItemsListByStatementId(Long statementId);


    /**
     * 创建对账单明细
     *
     * @param reqVO 创建对账单参数
     * @return 编号
     */
    Boolean generateFinanceStatement(ErpFinanceStatementPageReqVO reqVO);

    List<ErpFinanceStatementDO> batchSaveFinanceStatement(List<ErpFinanceStatementDO> list);
    void batchSaveFinanceStatementItem(List<ErpFinanceStatementItemsDO> list);

    PageResult<ErpFinanceStatementVO> pageFinanceStatement(PageErpFinanceStatementDTO dto);

    List<ErpFinanceStatementDO> getListByFinanceStatementNos(Collection<String> financeStatementNos);

    void removeFinanceStatementById(Long id);
    void removeFinanceStatementItemByItemIds(Collection<Long> itemIds);
    boolean existById(Long id);
    void backfillTransactionAmount(List<ErpFinanceStatementDO> list);
    List<ErpFinanceStatementDO> getFinanceStatementList(Collection<Long> statementIds);
    void batchChangeTransactionAmount(List<ErpFinanceStatementDO> list);

}